var roleTypeNum = $("#roleTypeNum").val(); 
var msgg = $("#msgg").val();
var code = $("#code").val();
$(function(){
	if( code== 1) {
		layer.msg(msgg);
	}
})
//操作按钮
function buttonFormatter(value, row, index) {
	if(row.rowId == 1){
		return "";
	}
 	var e = "<button id='btn_edit' type='button' onclick='addRoleType("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-pencil'></span>修改</button>";  
 	var d = "<button id='btn_edit' type='button' onclick='deleteRole("+row.rowId+",\""+row.roleName+"\");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-remove'></span>删除</button>";  
  	return e+'&nbsp;'+d;
}

//删除
function deleteRole(rowId, roleName){
	layer.confirm('您确认删除角色<a style="color:red">'+'"'+roleName+'"'+'</a>吗？', {
  	btn: ['确认', '取消'] //可以无限个按钮
	}, 
	function(){
		if (rowId == null || rowId == '') {
			layer.msg("删除失败,id不能为空!");
			return;
		}
		$.post(JSSYSMANAGERV1 + "/roleType/roleTypeDelete?rowId="+rowId,function(result){
			//正数为正确的提示   负数 为错误
 			var err = {'0':'删除成功','-1':'删除失败'};
			if (result != null  && result != '') {
  		  		layer.msg(err[result]);
  		  		roleFind();
  			}
	  	});
	}, function(){
		return;
	});
}
  
  
//添加/修改
function addRoleType(id){
  	layer.open({
	  	type: 2,
	  	title: "添加角色类型",
	  	closeBtn: 1,
	  	shadeClose: true,
	  	area: ['500px', '300px'],
	  	content: JSSYSMANAGERV1 + '/roleType/roleTypeEditer?rowId=' + id,
	 	btn: ["确 认","关 闭"],
	  	yes: function(index, layero){
	    	var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
			iframeWin.add();
	  	}
	});
}

$(function(){
  	$("#roleTable").bootstrapTable({ 
		url: JSSYSMANAGERV1 + "/roleType/roleType.json",
		method:"get", 
		pagination:true,
		sidePagination:"server",
		queryParams: function(params) {
  			return $.extend({}, params, parseJson(decodeURIComponent($("#roleForm").serialize())));     
 		}
 	}); 
})
function roleFind(){
  	$("#roleTable").bootstrapTable("refresh",{} ); 
}
 